package com.design.designmode.action.iter;

/**
 * @author hxl
 * @since 2023-04-18
 */
public class BookIterator implements CustomIterator {

    private int index;
    private BookAggregate aggregate;

    public BookIterator(BookAggregate aggregate) {
        this.aggregate = aggregate;
        this.index = 0;
    }

    @Override
    public boolean hasNext() {
        return this.index < aggregate.getSize();
    }

    @Override
    public Object next() {
        return aggregate.get(++index);
    }
}
